package com.langshixiaobai.domain.service;

import com.langshixiaobai.domain.model.entity.MarketProductEntity;
import com.langshixiaobai.domain.model.entity.TrialBalanceEntity;
import com.langshixiaobai.domain.service.trial.AbstractGroupBuyMarketSupport;
import com.langshixiaobai.domain.service.trial.factory.DefaultActivityStrategyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


//
@Service
public class IIndexGroupBuyMarketServiceImp implements IIndexGroupBuyMarketService {

    // 策略工厂
    @Autowired
    private DefaultActivityStrategyFactory defaultActivityStrategyFactory;

    @Override
    public TrialBalanceEntity indexStrategy(MarketProductEntity marketProductEntity) throws Exception {

        AbstractGroupBuyMarketSupport<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> strategy = defaultActivityStrategyFactory.strategyHandler();
        //营销商品实体信息 为入参 ， context 是上下文
        TrialBalanceEntity trialBalanceEntity = strategy.apply(marketProductEntity, new DefaultActivityStrategyFactory.DynamicContext());
        // 返回试错结果
        return trialBalanceEntity;


    }
}
